package com.cskaoyan.mall.payment.alipay.factory;

import com.cskaoyan.mall.payment.alipay.AlipayHelper;
import com.cskaoyan.mall.payment.alipay.PayHelper;
import com.cskaoyan.mall.payment.constant.PaymentType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
 * 使用工厂模式，生产对于不同支付方式对应的工具类，用他们发起请求访问接口
 * @author Macro_Ray
 * @since 2024/6/25 下午2:33
 */
@Component
public class SimplePayHelperFactory implements PayHelperFactory{

    @Autowired
    AlipayHelper alipayHelper;

    @Override
    public PayHelper getPayHelper(PaymentType paymentType) {
        if (PaymentType.ALIPAY.equals(paymentType)) {
            return alipayHelper;
        }            // 如果有其他的支付可以继续添加 else if
        return null;
    }
}
